import time
from flcliapi import FreelanceClient


def main():
    client = FreelanceClient()
    client.connect("tcp://localhost:5555")
    # client.connect("tcp://localhost:5556")
    # client.connect("tcp://localhost:5557")

    requests = 10000
    start = time.time()
    for i in range(requests):
        request = ["random name"]
        reply = client.request(request)
        if not reply:
            print("E: name service not available, aborting")
            return
    print("Average round trip cost: %d usec" % (1e6* (time.time() - start)/requests))


if __name__ == '__main__':
    main()